class Solution:
    def quick(self, x, n):

        ans = 1
        cur = x
        while n > 0:
            if n % 2 == 1:
                ans *= cur
            n //= 2
            cur *= cur

        return ans

    def myPow(self, x: float, n: int) -> float:
        if n > 0:
            return self.quick(x, n)
        elif n == 0:
            return 1
        else:
            return 1 / (self.quick(x, -n))


if __name__ == '__main__':
    s = Solution()
    print(s.myPow(2, 10))
